#ifndef DLGMIXIN_H_9C889376_DB3D_465B_8B7A_E4F0D0DAF90F
#define DLGMIXIN_H_9C889376_DB3D_465B_8B7A_E4F0D0DAF90F
/**
 * \file DlgMixin.h
 *
 * \brief Header file for template class CDlgMixin
 *
 * $Id: DlgMixin.h,v 1.1.1.1 2008/04/23 13:29:14 mgh Exp $
 *
 *
 * Copyright (C) 2006 Michael G. Herstine <sp1ff@pobox.com>
 *
 * Permission to use, copy, or modify this source code is hereby granted
 * free of  charge, provided  that this copyright  notice appear  on all
 * copies  and  on   all  source  code  derived  from   this  code.   No
 * representation is made regarding the suitability of this software for
 * any  purpose.  It  is provided  "as  is" without  express or  implied
 * warranty.
 *
 *
 */

/**
 * \class CDlgMixin
 *
 * \brief Mixin class implementing basic configuration dialog behavior
 *
 * \sa CPropPageCtl, CConfigDlg
 *
 *
 * Some hosts allow us to integrate our configuration dialog(s) into the
 * Property Sheet they display in Tools | Options by implementing a COM
 * Composite Control.  Others do not, and we implement our own ATL
 * CDialogImpl subclass.
 *
 * To avoid replicating code between those two classes, I've implemented
 * the dialog's behavior in this class CDlgMixin, which is intended to
 * be used as a base class by both our UI widgets.  In the case of this
 * app, it may seem silly since the configuration is so simple, but in a
 * real Add-In this class would become more complex & larger (and
 * represent a greater code savings over duplication).
 *
 *
 */

template <typename T>
class CDlgMixin
{
public:
  BEGIN_MSG_MAP(CDlgMixin)
  END_MSG_MAP()

  void OnInitDialog(WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
  {
    T* pT = (T*)this;
    pT->SetDlgItemText(IDC_EDIT_PHRASE, pT->getHello().c_str());
  }

  LRESULT OnClickedOK()
  {
    char lpszBuffer[MAX_HELLO_PHRASE];

    T* pT = (T*)this;
    pT->GetDlgItemText(IDC_EDIT_PHRASE, lpszBuffer, MAX_HELLO_PHRASE);
    pT->setHello(lpszBuffer);

    return 0L;
  }

};

// Local Variables:
// fill-column: 72
// indent-tabs-mode: nil
// show-trailing-whitespace: t
// End:

#endif // DLGMIXIN_H_9C889376_DB3D_465B_8B7A_E4F0D0DAF90F
